package com.android.fragmentdemo.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.android.fragmentdemo.FiledConstant

class ShutDownBroadcastReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context?, intent: Intent?) {
        if (context == null || intent == null) {
            return
        }
        when (intent.action) {
            Intent.ACTION_BOOT_COMPLETED -> {
                //开机完成
                Log.d(TAG, "Intent.ACTION_BOOT_COMPLETED")
            }
            Intent.ACTION_MY_PACKAGE_REPLACED -> {
                //APK替换安装
                Log.d(TAG, "Intent.ACTION_BOOT_COMPLETED")
            }
            Intent.ACTION_PACKAGE_ADDED -> {
                //APK安装
                Log.d(TAG, "Intent.ACTION_BOOT_COMPLETED")
            }
            Intent.ACTION_PACKAGE_REMOVED -> {
                //APK卸载
                Log.d(TAG, "Intent.ACTION_BOOT_COMPLETED")
            }
            Intent.ACTION_PACKAGES_SUSPENDED -> {
                //APK卸载
                Log.d(TAG, "Intent.ACTION_BOOT_COMPLETED")
            }
            Intent.ACTION_BATTERY_LOW -> {
                //低电量
                Log.d(TAG, "Intent.ACTION_BATTERY_LOW")
            }
            Intent.ACTION_SCREEN_ON -> {
                //亮屏
                Log.d(TAG, "Intent.ACTION_SCREEN_ON")
            }
            Intent.ACTION_SCREEN_OFF -> {
                //息屏
                Log.d(TAG, "Intent.ACTION_SCREEN_OFF")
            }
            Intent.ACTION_APP_ERROR -> {
                //The user pressed the "Report" button in the crash/ANR dialog.报告ANR时点击了确定按钮
            }
            Intent.ACTION_POWER_CONNECTED -> {
                //接通电源
            }
            Intent.ACTION_CONFIGURATION_CHANGED -> {
                //配置发生改变
                Log.d(TAG, "Intent.ACTION_CONFIGURATION_CHANGED")
            }
            Intent.ACTION_REBOOT -> {
                //重启
                Log.d(TAG, "Intent.ACTION_REBOOT")
            }
            Intent.ACTION_POWER_DISCONNECTED -> {
                //电源断开
                Log.d(TAG, "Intent.ACTION_POWER_DISCONNECTED")
            }
            Intent.ACTION_SHUTDOWN -> {
                //电源断开
                Log.d(TAG, "Intent.ACTION_SHUTDOWN")
            }
            FiledConstant.ACTION_TEST_RECEIVER -> {
                Log.d(TAG, "ACTION_TEST_RECEIVER")
            }
        }
    }

    companion object {
        const val TAG = "ShutDownBroadcastReceiver"
    }
}